/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._2BinarySearch_PrefixSum
 * @File : Q0796.java
 * @Author : WangRuoyu
 * @Date 2023/3/13 22:46
 */

package acwing._2LanQiao._2BinarySearch_PrefixSum;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._2BinarySearch_PrefixSum
 * @File : Q0796.java
 * @Author : WangRuoyu
 * @Date 2023/3/13 22:46
 */

public class Q0796 {
    public static void main(String[] args) throws IOException {
//        Scanner scan = new Scanner(System.in);
//        int m = scan.nextInt();
//        int n = scan.nextInt();
//        int q = scan.nextInt();

        String line;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        line = br.readLine();
        String[] words = line.split(" ");
        int m = Integer.parseInt(words[0]);
        int n = Integer.parseInt(words[1]);
        int q = Integer.parseInt(words[2]);

        int[][] d = new int[m][n];
        int[][] s = new int[m + 1][n + 1];

        for (int i = 0; i < m; i++) {
            line = br.readLine();
            words = line.split(" ");
            for (int j = 0; j < n; j++) {
                d[i][j] = Integer.parseInt(words[j]);
            }
        }

        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                s[i][j] = d[i - 1][j - 1] + s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
            }
        }

        for (int i = 0; i < q; i++) {
            line = br.readLine();
            words = line.split(" ");

            int x1 = Integer.parseInt(words[0]);
            int y1 = Integer.parseInt(words[1]);
            int x2 = Integer.parseInt(words[2]);
            int y2 = Integer.parseInt(words[3]);

            System.out.println(s[x2][y2] - s[x2][y1 - 1] - s[x1 - 1][y2] + s[x1 - 1][y1 - 1]);
        }
    }
}

//3 4 3
//1 7 2 4
//3 6 2 8
//2 1 2 3
//1 1 2 2
//2 1 3 4
//1 3 3 4
